<form id="changephone_old" method="post" enctype="multipart/form-data">
    <p style="font-size: 13px;color: red;line-height: 30px;text-align: center;background-color: #f1f1f1">
        <span>{$phone}</span>
        <a href="JavaScript:;" id="yzm" class="go" style="margin-left:20px;text-decoration:none;display:inline-block;width:120px;border-radius:5px;line-height: 30px;height: 30px;background-color: dodgerblue;color:#fff;text-align: center;font-size: 14px">
            获取验证码
        </a>
    </p>
    <div class="row row1">
        <label class="col-sm-2 control-label">验证码：</label>
        <div class="col-sm-5">
            <input type="text" class="form-control" name="usercode" placeholder="请输入验证码">
        </div>

    </div>
</form>
<script>
    var intv;
    $('#yzm').click(function () {
        if($(this).hasClass('go')){
            $('#yzm').css({'background-color':'#ccc'});
            $('#yzm').text('59秒后重新获取');
            $('#yzm').removeClass('go');
            intv = setInterval("timego()",1000);
            $.ajax({
                url:'admin/Admin/getPhoneCode',
                data:'type=1',
                type:'POST',
                dataType:'JSON',
                success:function(returndata){
                    if (returndata.status != 200) {
                        $.TeachDialog({
                            content: returndata.msg
                        });
                    }
                },
                error: function () {
                    $.TeachDialog({
                        content: '系统异常，请联系管理员'
                    });
                }
            });
        }else{
            return;
        }
    });
    function timego() {
        var m = parseInt($('#yzm').text());
        var nm = m-1;
        if(nm > 0){
            $('#yzm').text(nm+'秒后重新获取');
        }else{
            $('#yzm').css({'background-color':'dodgerblue'});
            $('#yzm').text('获取验证码');
            $('#yzm').addClass('go');
            clearInterval(intv);
            return;
        }

    }
</script>

